package org.adream.account.service;

import org.adream.account.dao.LoginPageFilesDao;
import org.adream.account.entity.LoginPageFilesEntity;
import org.adream.account.entity.LoginStarLogEntity;
import org.adream.account.util.IdGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginPageFilesService {
	
	@Autowired
	LoginPageFilesDao loginPageFilesDao;
	
	public LoginPageFilesEntity getLoginPageInfo() {
		return loginPageFilesDao.getLoginPageInfo();
	}

	public int addLoginStarLog(String addr, String code) {
		LoginPageFilesEntity entity = loginPageFilesDao.getLoginPageInfo();
		if(entity == null) {
			return 0;
		}
		LoginStarLogEntity logEntity = new LoginStarLogEntity();
		logEntity.setId(IdGenerator.getGuid());
		logEntity.setAddr(addr);
		logEntity.setCode(code);
		logEntity.setLpfId(entity.getLpfId());
		
		return loginPageFilesDao.addLoginStarLog(logEntity);
	}

	public int getCountByLpfId(String lpfId) {
		return loginPageFilesDao.getCountByLpfId(lpfId);
	}
	
}
